<template>
	<view class="my">
		<view class="ot">

		</view>
		<view class="header">
			<image :src="userInfo.avatar" mode=""></image>
			<view class="detail">
				<view class="" style="font-weight: 600;font-size: 36rpx;">
					{{userInfo.username}}
				</view>
				<!-- 	<view class="" style="color: #717171;font-size: 24rpx;">
					{{userInfo.nickname}}
				</view> -->
			</view>
			<!-- 			<view class="edit">
				编辑
			</view> -->
		</view>
		<view class="items">
			<view class="item" @click="toAddress">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="map" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						我的地址
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item" @click="toCoupon">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="coupon" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						我的优惠券
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item" @click="scan" v-if="show">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="grid" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						核销服务订单
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item" @click="toInvite">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="man-add" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						邀请二维码
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item" @click="toGoodsOrder">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="tags" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						养车订单
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item" @click="es">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="order" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						二手车市场订单
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item" style="border-bottom: 0;" @click="addgoods">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="plus" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						发布二手车
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<!-- 			<view class="item" @click="toOrders" style="border-bottom: 0;">
				<view class="" style="display: flex;align-items: center;">
					<u-icon name="tags" color="##999999" size="20"></u-icon>
					<view class="" style="margin-left: 16rpx;">
						养车订单
					</view>
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view> -->
			<button open-type="contact">
				<view class="item2">
					<view class="" style="display: flex;align-items: center;">
						<u-icon name="chat" color="##999999" size="20"></u-icon>
						<view class="" style="margin-left: 16rpx;">
							联系客服
						</view>
					</view>
					<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
				</view>
			</button>

			<!-- 			<view class="item">
				<view class="" style="display: flex;align-items: center;">
					<image src="../../static/img/item1.png" mode=""></image>
					服务记录
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>
			<view class="item">
				<view class="" style="display: flex;align-items: center;">
					<image src="../../static/img/item1.png" mode=""></image>
					购物记录
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view>

			<view class="item">
				<view class="" style="display: flex;align-items: center;">
					<image src="../../static/img/item1.png" mode=""></image>
					我的客服
				</view>
				<u-icon name="arrow-right" color="##999999" size="14"></u-icon>
			</view> -->
		</view>
		<view class="btn" @click="logout">退出登录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				show: false
			}
		},
		onLoad() {
			let token = uni.getStorageSync('token')
			if (!token) {
				uni.reLaunch({
					url: "/pages/login/login"
				})
				return
			}
			this.userInfo = uni.getStorageSync("userInfo")
			if (this.userInfo.group_id == 2) {
				this.show = true;
			}
		},
		methods: {
			es() {
				uni.navigateTo({
					url: "/pagesA/esOrders/esOrders"
				})
			},
			scan() {
				uni.showLoading()
				let that = this;
				uni.scanCode({
					success: function(res) {
						let json = JSON.parse(JSON.stringify(res))
						console.log('json', json)
						let code = null;
						code = json.path.split('=')[1]
						// let systemInfo = uni.getSystemInfoSync();
						// if (systemInfo.system.indexOf('iOS') > -1) {
						// 	code = json.path.split('3D')[1]
						// } else {
						// }
						uni.navigateTo({
							url: "/pages/detailById/detailById?id=" + code
						})
						console.log(code)
					},
					complete(res) {
						uni.hideLoading()
					}
				});
			},

			addgoods() {
				uni.navigateTo({
					url: '/pagesA/mygoods/mygoods'
				})
			},
			logout() {
				uni.removeStorageSync("token")
				uni.removeStorageSync("userInfo")
				uni.reLaunch({
					url: "/pages/index/index"
				})
			},
			toInvite() {
				uni.navigateTo({
					url: "/pages/invite/invite"
				})
			},
			toCoupon() {
				uni.navigateTo({
					url: "/pages/coupon/coupon"
				})
			},
			toAddress() {
				uni.navigateTo({
					url: "/pages/address/address"
				})
			},
			toOrders() {
				uni.navigateTo({
					url: "/pages/myOrders/myOrders"
				})
			},
			toGoodsOrder() {
				uni.navigateTo({
					url: "/pages/myOrders2/myOrders"
				})
			},
		}
	}
</script>
<style>
	page {
		background-color: #ffffff;
	}
</style>
<style scoped lang="scss">
	.ot {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 600rpx;
		background-color: #75D65E;
		background: linear-gradient(to bottom, #75D65E, #ffffff, #ffffff);
	}

	button {
		height: 102rpx !important;
		background-color: white !important;
		padding: 0 30rpx !important;
		font-size: 32rpx !important;
		display: flex;
		align-items: center;
	}

	.btn {
		margin: 0 100rpx;
		margin-top: 30rpx;
		padding: 20rpx 0;
		text-align: center;
		color: white;
		font-size: 28rpx;
		border-radius: 20px;
		// box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.302);
		background: linear-gradient(90deg, #75D65E 0%, #75D65E 100%);
	}

	.item2 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: white;
		width: 100%;
	}

	.my {
		.header {
			display: flex;
			align-items: center;
			position: relative;
			z-index: 1;
			padding: 50rpx 30rpx;

			.edit {
				background-color: #41CE70;
				color: white;
				padding: 2rpx 24rpx;
				border-radius: 100px;
				border: 2px solid rgba(65, 206, 112, .3);
			}

			image {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
				border: 2px solid white;
				margin-right: 20rpx;
			}

			.detail {
				flex: 1;
				height: 120rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-evenly;
			}
		}

		.items {
			z-index: 1;
			position: relative;
			padding-bottom: 0;

			.item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: white;
				padding: 30rpx;
				font-size: 32rpx;
				border-bottom: 1rpx solid rgba(0, 0, 0, .1);

				image {
					width: 40rpx;
					height: 40rpx;
					margin-right: 12rpx;
				}
			}
		}
	}
</style>